<div class="parent">
    <div class="child">测试示例</div>
  </div>
  <style>
    .parent {
      height: 100px;
      background-color: aqua;
    }
    .child {
      background-color: blueviolet;
      color: #fff;

      width:fit-content;
      margin:0 auto;
    }
  </style>